#include "dummyaccel.h"
#include <iostream>
#include <QDebug>
#include "intersection.h"


using namespace std;

DummyAccel::DummyAccel(const vector<Primitive* > &p)
{
    primitives = p;
    for (uint32_t i = 0; i < primitives.size(); ++i) {
        BBox b = primitives[i]->WorldBound();
        bounds = Union(bounds, b);
    }

}

DummyAccel::~DummyAccel(){
}

bool DummyAccel::Intersect(const Ray &ray, Intersection *isect) const {

    bool hit = false;
    for (int i = 0; i< primitives.size() ; i++) {
        if (primitives[i]->Intersect(ray, isect)) {
            hit = true;
            }
    }

    if (hit) return true;
    return false;
}



bool  DummyAccel::IntersectP(const Ray &ray) const{
    for (int i = 0; i< primitives.size() ; i++) {
        if (primitives[i]->IntersectP(ray))
            return true;
    }

    return false;
}

